<template>
  <div>
    <div @click="ceshi">{{index}}</div>
    <div>{{item}}</div>
    <img src="../static/timg.jpg" alt @click="go" />
    <div>
      <p class="back">渲染这里</p>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  asyncData({ store, route }) {
    axios.get('/api/1').then(res=>{
      console.log(res)
    })
    // 触发 action 后，会返回 Promise
    return store.dispatch("fetchItem", 2);
  },
  computed: {
    // 从 store 的 state 对象中的获取 item。
    item() {
      return this.$store.state.count;
    }
  },
  data() {
    return {
      index: 1
    };
  },
  mounted() {
    this.index = 2;
  },
  methods: {
    ceshi() {
      console.log(1);
    },
    go() {
      console.log(this.$route);
    }
  }
};
</script>

<style>
.back {
  background: #000;
}
</style>